<template>
	<view class="center">
		<u-search shape="round" placeholder="请输入你的姓名/手机号/身份证号" @search="userinfoData(keyword)" v-model="keyword"
			:clearabled="true" animation @custom="custom"></u-search>

		<view class="formData">
			<view class="zoneBox">
				<view class="information" v-for="item in userList" :key="item" @click="information(item)">
					<view class="title">{{item.username}}</view>
					<view class="title">{{item.tel}}</view>
					<view class="title">{{item.paid_name}}</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		signup
	} from '../../api/user'
	export default {
		data() {
			return {
				keyword: '',
				userList: [],
				uuid: 0
			};
		},
		onLoad(options) {
			this.uuid = options.id
		},
		methods: {
			custom(e) {
				console.log(e);
				if (e == '') {
					uni.showToast({
						title: '请输入关键词',
						duration: 1000,
					})
				} else {
					this.userinfoData(e)
				}

			},
			async userinfoData(e) {
				await signup({
					username: e
				}).then(res => {
					console.log(res, '查询');
					if (res.status == 200) {
						this.userList = res.data
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			information(e) {
				let id = e.order_id
				if (this.uuid == 1) {
					uni.navigateTo({
						url: '/pages/weight/weight?id=' + id
					})
				} else {
					uni.navigateTo({
						url: '/pages/invoicing/invoicing?id=' + id
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	.center {
		margin: 20rpx;

		.formData {
			padding: 0 20rpx;

			.zoneBox {
				margin-top: 15rpx;

				.information {
					display: flex;
					align-items: center;
					justify-content: space-between;
					border: 1rpx solid $uni-border-color;
					border-radius: 20rpx;
					margin: 10rpx 0;
					padding: 20rpx;

					.title {
						font-size: 28rpx;
						color: #50566a;
					}
				}
			}
		}
	}
</style>